#include <bits/stdc++.h>

using namespace std;

int main_1008_2()
{
    int N,M,right;
    scanf("%d%d",&N,&M);
    int seq[N]= {0};
    for (int i=0; i<N ; ++i )
    {
        scanf("%d",&seq[i]);
    }
    M%=N;
    for (int i=0; i<M ; ++i )
    {
        right=seq[N-1];
        for (int j=N-1; j>0 ; --j )
        {
            seq[j]=seq[j-1];
        }
        seq[0]=right;
    }
    --N;
    for (int i=0; i<N ; ++i )
    {
        printf("%d ",seq[i]);
    }
    printf("%d",seq[N]);
    return 0;
}
